package com.sky.controller.User;
import com.sky.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

@RestController("UserShopController")
@RequestMapping("user/shop")
@Api(tags = "店铺相关接口")
@Slf4j
public class ShopController {

    @Autowired
    private RedisTemplate redisTemplate;

    private final String key = "SHOP_STATUS";


    /**
     * 查询店铺营业状态
     * @return
     */
    @GetMapping("/status")
    @ApiOperation(value = "查询店铺营业状态")
    public Result<Integer> getShopStatus(){
        Integer result =  (Integer) redisTemplate.opsForValue().get(key);
        log.info("店铺当前的营业状态为:{}",result == 1? "营业中":"打烊中");
        System.out.println(result);
        return Result.success(result);
    }
}
